//
//  HomeCellDisplayCollectionViewCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/20.
//  Copyright © 2018年 guoshikeji. All rights reserved.
//

#import "HomeCellDisplayCollectionViewCell.h"

@implementation HomeCellDisplayCollectionViewCellSingle

+ (instancetype)shared {
    static HomeCellDisplayCollectionViewCellSingle *sm = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (!sm) {
            sm = [[HomeCellDisplayCollectionViewCellSingle alloc] init];
            sm.label = [self singleLabel];
        }
    });
    return sm;
}


+ (QMUILabel *)singleLabel {
    QMUILabel *lb = [QMUILabel new];
    lb.font = [UIFont systemFontOfSize:11 weight:UIFontWeightRegular];
    lb.textColor = [UIColor qmui_colorWithHexString:@"#9B9B9B"];
    lb.contentEdgeInsets = UIEdgeInsetsMake(3, 6, 3, 6);
    lb.textAlignment = NSTextAlignmentCenter;
    return lb;
}

@end

@interface HomeCellDisplayCollectionViewCell ()

@property (nonatomic, strong) QMUILabel *displayLabel;

@end

@implementation HomeCellDisplayCollectionViewCell



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 2;
        self.layer.borderColor = [UIColor qmui_colorWithHexString:@"#C2C2C2"].CGColor;
        self.layer.borderWidth = 1;
        //
        self.displayLabel = [HomeCellDisplayCollectionViewCellSingle singleLabel];
        [self addSubview:self.displayLabel];
        [self.displayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(self);
        }];
    }
    return self;
}

- (void)setDisplayString:(NSString *)displayString {
    _displayString = displayString;
    self.displayLabel.text = displayString;
}

+ (CGSize)itemSizeWithDisplayString:(NSString *)displayString {
    QMUILabel *label = [HomeCellDisplayCollectionViewCellSingle shared].label;
    label.text = displayString;
    [label sizeToFit];
    return label.bounds.size;
}

@end
